<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>毕业设计</title>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"></link>
	<script src="/js/layer/layer.js}"></script>
	<script src="/common/common.js}"></script>
    <script type="text/javascript" src="/jquery-3.3.1.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/showItems.js"></script>
    <script type="text/javascript" src="/js/editActivity.js"></script>
</head>
<body class="gray-bg">
        <div class="wrapper wrapper-content animated fadeInRight">
        <input type="hidden"  name="activityItemId" id="activityItemId" th:value="${activityItemId}" value="商品id"/>
        <input type="hidden"  name="activityId" id="activityId"  value=""/>
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
				<form action="#" method="post">
					<div class="ibox-body">
                              <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require"> 活动名称：</label>
                                <div class="col-sm-8">
                                    <input id="marketName" class="form-control"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
                               <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require">商品价格：</label>
                                <div class="col-sm-8">
                                    <input id="price" class="form-control"  type="text"  autocomplete="off" value="" readonly="readonly"/>
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require" >活动价格：</label>
                                <div class="col-sm-8">
                                    <input id="marketItemPrice" class="form-control"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
							
							  <div class="form-group">
	                            <label class="col-sm-3 control-label am-label-require"> 开始时间：</label>
                                <div class="col-sm-8">
                                    <input id="startDate" class="form-control"  type="text" autocomplete="off" value=""/>
                                </div>
                              </div>
                             <div class="form-group">
	                            <label class="col-sm-3 control-label am-label-require"> 结束时间：</label>
                                <div class="col-sm-8">
                                    <input id="endDate" class="form-control"  type="text" autocomplete="off" value=""/>
                                </div>
                              </div>
						</div>
					</form>
					</div>
				</div>
			</div>
			<br>
				<div align="center">
					<button class="button button-pill" onclick="upAct()" style="width: 55px;height: 35px" >修改</button>&nbsp;&nbsp;&nbsp;
		            <button class="button button-pill" onclick="reset()" style="width: 55px;height: 35px;" >取消</button>
	            </div>
	</div>
</body>

<script type="text/javascript">
//定义全局商品信息数组
jQuery(document).ready(function(){
	var itemId = $("#activityItemId").val();
	$.ajax({
        url: "/showActByItemId?itemId="+itemId,
        type: "GET",
        cache: false,
        success: function (data) {  
        	if (data.status == "success") {
                //获取成功的操作
        		itemBo=data.data;
        		reloadDom();
             } else {
             	alert("获取商品信息失败,原因为: "+data.data);
             }
        }
    })
    
    function reloadDom(){
		 $("#marketName").val(itemBo.marketBo.marketName);   
		 $("#activityId").val(itemBo.marketBo.id);
         $("#price").val(itemBo.price);
         $("#marketItemPrice").val(itemBo.marketBo.marketItemPrice);
            var time=new Date(itemBo.marketBo.startDate);
			var month=1+time.getMonth();
			var startDate=time.getFullYear();
			if(month<=9){
				startDate=startDate+" - 0"+ month;
			}else{
				startDate=startDate+" - "+ month;
			}
			if(time.getDate()<=9){
				startDate=startDate+" - 0"+time.getDate();
			}else{
				startDate=startDate+" - "+time.getDate();
			}
			if(time.getHours()<=9){
				startDate=startDate+"  0"+time.getHours()+":";
			}else{
				startDate=startDate+" "+time.getHours()+":";
			}
			if(time.getMinutes()<=9){
				startDate=startDate+"0"+time.getMinutes();
			}else{
				startDate=startDate+time.getMinutes();
			}
			if(time.getSeconds()<=9){
				startDate=startDate+":0"+time.getSeconds();
			}else{
				startDate=startDate+":"+time.getSeconds();
			}
         $("#startDate").val(startDate);
         var time1=new Date(itemBo.marketBo.endDate);
			var month=1+time1.getMonth();
			var endDate=time1.getFullYear();
			if(month<=9){
				endDate=endDate+" - 0"+ month;
			}else{
				endDate=endDate+" - "+ month;
			}
			if(time1.getDate()<=9){
				endDate=endDate+" - 0"+time1.getDate();
			}else{
				endDate=endDate+" - "+time1.getDate();
			}
			if(time1.getHours()<=9){
				endDate=endDate+"  0"+time1.getHours()+":";
			}else{
				endDate=endDate+" "+time1.getHours()+":";
			}
			if(time1.getMinutes()<=9){
				endDate=endDate+"0"+time1.getMinutes();
			}else{
				endDate=endDate+time.getMinutes();
			}
			if(time1.getSeconds()<=9){
				endDate=endDate+":0"+time1.getSeconds();
			}else{
				endDate=endDate+":"+time1.getSeconds();
			}
         $("#endDate").val(endDate);
	}
})


//撤销修改
function reset() {
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}

</script>

</html>
